//
//  CategoryDemoViewController.m
//  CategoryKit
//
//  Created by xinpenghui on 16/12/6.
//  Copyright © 2016年 Wanda. All rights reserved.
//

#import "CategoryDemoViewController.h"
#import "AppUIDefine.h"
#import "FormatViewController.h"
#import "DataOrganViewController.h"

#import "OtherViewController.h"
#import "SafeCategoryViewController.h"

#import "WDViewController.h"

@interface CategoryDemoViewController () <UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *dataArray;
@end

@implementation CategoryDemoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"CategoryKit-Demo";
    [self setData];
    [self loadSubView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setData {
    
    self.dataArray = @[@"Format",@"DataOrganization",@"FIleManager",@"Runtime",@"SafeCategory",@"UIFactory",@"AutoParser",@"Other"];
    
}

- (void)loadSubView {

    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kDefaultWindowWidth, kDefaultWindowHeight) style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.tableFooterView = [UIView new];
    [self.view addSubview:self.tableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *identifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = [self.dataArray objectAtIndex:indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        FormatViewController *view = [[FormatViewController alloc] init];
        [self.navigationController pushViewController:view animated:YES];
    }
    else if (indexPath.row == 1) {
        DataOrganViewController *view = [[DataOrganViewController alloc] init];
        [self.navigationController pushViewController:view animated:YES];
    }
    
    else if (indexPath.row == 4) {
        SafeCategoryViewController *view = [[SafeCategoryViewController alloc] init];
        [self.navigationController pushViewController:view animated:YES];
    }
    else if (indexPath.row == 5) {
        WDViewController *view = [[WDViewController alloc] init];
        [self.navigationController pushViewController:view animated:YES];
    }
    else if (indexPath.row == [self.dataArray count]-1) {
        OtherViewController *view = [[OtherViewController alloc] init];
        [self.navigationController pushViewController:view animated:YES];
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
